package socketdemo.aio;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @author zoush
 * @createTime 2024/12/12  9:59
 */
public class UserInputHandler implements Runnable{
    ChatClient client;

    public UserInputHandler(ChatClient client){
        this.client = client;
    }
    @Override
    public void run() {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            try {
                String input = bufferedReader.readLine();
                client.send(input);
                if(input.equals("quit"))
                    break;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}